<template>
  <div class="assess">
    <Header></Header>
    <div class="assessMain">
      <div class="mianOut mt20">
        <div class="mianInner1">
          <div class="assess-title2">
                <p :class="planSummaryName?'':'noPlanClass'"><img src="../../../static/images/sound.png" />提示信息：您收到{{planSummaryName}}，需要您进行评审工作。</p>      
            <ul class="clearfix">
              <li @click="$router.push('waitAssess2')">待评审</li>
              <li class="active"
                  @click="$router.push('assessed2')">已评审</li>
            </ul>
            <h4>已评审预案</h4>
          </div>
          <el-table ref="multipleTable"
                    :data="reviewedList">
            <el-table-column type="index"
                             align='center'
                             label='序号'
                             width="150">
            </el-table-column>
            <el-table-column prop="reviewStartTime"
                             label="评审时间"
                             align='center'
                             width='350'>
                <template slot-scope="scope">
                    <p><span>{{scope.row.reviewStartTime | timeBy}}</span>到<span>{{scope.row.reviewEndTime | timeBy}}</span></p>
                </template>
            </el-table-column>
            <el-table-column prop="planSummaryName"
                             label="评审预案任务"
                             align='center'
                             show-overflow-tooltip>
            </el-table-column>
            <el-table-column label="操作"
                             align='center'
                             width='280'>
                              <template slot-scope="scope">
                            <el-button class='detail-btn'
                            @click="$router.push({name:'checkAssessed2',query:{id:scope.row.planSummaryId}})"><i class="el-icon-search">查看</i></el-button>
                            
                         <el-button v-if="scope.row.isFlag == 0 " class='detail-btn'
                         @click="goPath(scope.row)"><i class="el-icon-edit">意见汇总</i></el-button>
					</template>
            </el-table-column>
          </el-table>
          <div class="page-container">
            <el-pagination :pager-count='5'
                           @current-change="handleCurrentChange"
                           :current-page="currentPage"
                           :page-size="pageSize"
                           layout="total, prev, pager, next, jumper"
                           :total="total">
            </el-pagination>
            <el-button>确定</el-button>
          </div>
        </div>
      </div>
    </div>
    <Footer />
  </div>
</template>

<script>
import Header from '../common/header2'
import Footer from '../common/footer'
import config from '../../config.js'
export default {
  components: {
    Header,
    Footer
  },
  data () {
    return {
      reviewedList: [],
      currentPage: 1,
      pageSize: 10,
      total: 0,
      planSummaryName: ''
    };
  },
  created(){
      this.planSummaryName = this.$route.query.name
    this.getreviewedList()
  },
  filters: {
      timeBy(val){
          if(val){
              return val.substring(0,10)
          }
      }
  },
  methods: {
     getQuery (id) {
        let url = config.baseUrl + 'bsReviewSendCompany/v1.0/company/query?planSummaryId='+id

         this.$axios(url)
         .then((res) =>{
           let arr =  this.reviewedList
            if(res.data.meta.success){
              
               arr.map(item=>{
                  if(item.planSummaryId == id){
                    item.isFlag = 2
                  }
                })
            }else{
                  this.reviewedList.map(item=>{
                  if(item.planSummaryId == id){
                    item.isFlag = 0
                  }
                })
                console.log(arr)
            }  
            
                this.reviewedList = arr        
         })
      },
     goPath(obj){
         localStorage.planid=obj.planSummaryId
      localStorage.planname=obj.planSummaryName
      localStorage.planCompany = obj.companyName
      this.$router.push('assessedAll2')
      },
      getreviewedList () {
        let url = config.baseUrl + 'planreview/v1.0/planreview/querylist'
        let params = {
             "userId": JSON.parse(localStorage.getItem('user')).id,
             "current" : this.currentPage,
             "size": this.pageSize,
             "status": 1
         }

         this.$axios(url,{params: params})
         .then((res) =>{
            if(res.data.meta.success){
                if(res.data.data.records.length > 0){
res.data.data.records.map(item=>{
     item.isFlag=0
  if(item.identity==1){
    this.getQuery(item.planSummaryId)
  }else{
    item.isFlag=1
  }
})
                }
                this.reviewedList = res.data.data.records
                this.total = res.data.data.total
            }else{
                this.reviewedList = []
				this.total = 0
            }          
         })
      },
      handleCurrentChange (val) {
          this.currentPage = val
          this.getreviewedList()
        }
  }
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang='less'>
@import "../../../static/css/assess.less";
</style>
<style>
.noPlanClass{
    opacity: 0;
    filter: alpha(opacity=0);
}
</style>

